﻿from google.appengine.ext import webapp  
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp                                        
import os  
from utilities import *
from entities import *  
from datetime import date
import datetime
from xmlWs import * 
class Main(webapp.RequestHandler):
    def get(self):
        #Utils.signin(self)
        #tuyendungs = TuyenDungNguoiDungEntities.Get(Entities.GetKey())
        east = 105.87322950744624
        west = 105.83031416320796
        north = 21.049758499972302
        south = 21.009701561258304 
        #tuyendungs = TuyenDungNguoiDungEntities.Get(Entities.GetKey())  
        #TrangThaiID =  TrangThai.GetID(Entities.GetKey(), u'Hợp lệ')
        #trangthai = Entities.TrangThaiXetDuyet.get_by_id(TrangThaiID)
        #results = Entities.NhaTuyenDung.all().filter("TrangThaiID=", trangthai)
        #results = results.filter("ViTri >=", db.GeoPt(lat=south, lon = west)).filter("ViTri <=",db.GeoPt(lat=north, lon=east))

        #results = results.filter("__key__ IN", tuyendungs)       
        #TrangThaiID =  TrangThai.GetID(Entities.GetKey(), u'Hợp lệ')
        #trangthai = Entities.TrangThaiXetDuyet.get_by_id(TrangThaiID)
        #status = Entities.NhaTuyenDung.all().filter("TrangThaiID =", trangthai)
        #status = Entities.NhaTuyenDung.all()
        #status = status.filter("Email IN", tuyendungs)
        #status = Entities.NhaTuyenDung.all().filter("__key__ IN", tuyendungs)
        #status = Application.getNhaTuyenDung(Entities.GetKey(),0,0,0,0)
        
        #results = DonDangTuyen.Get(Entities.GetKey())
        #Utils.init_start()
        #status = NganhNgheNguoiDung.Add(Entities.GetKey(),159)
        #status = LinhVuc.Add("aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM", 158)
        keyLocal = "aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM"
        keyLongtdbk ="aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGD8M"
        #status = NhaTuyenDung.Get(keyLocal,"","",217,0,0,0)
        #status = NganhNghe.Add("aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM", 190)
        #status = LinhVuc.GetAll(keyLocal)
        #status = NganhNghe.Delete("aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM",190)
        #status  = NganhNghe.GetAll("aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM",0)
        #status = LinhVuc.Get("aghsb25ndGRia3IPCxIJTmd1b2lEdW5nGCoM",162)
        #status = DangTuyenDoiTuong.Get(keyLocal,224, 0)
        TenThuongHieu = "Thuong hieu toan cau hoa"
        MieuTa = "Khong co gi, chi 2 chu : Tuyet voi !"
        
        Email = "toancau12@gmail.com"
        SoDienThoai = "01453535353"
        LinhVucID = 163
        NguoiLienHe = "Long Dai ca"
        QuiMoID = 66
        Website = "http://toancau.com.vngr"
        AnhDaiDien = "/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gNzUK/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAawB4AwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQV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
        ViTriText = "ha Noi, Viet Nam"
        lat  =  20.996320146172714
        lng = 105.85160017395015
        TrangThaiID = 164
        NguoiDungID = 0 
        ViTri = db.GeoPt(lat=float(lat), lon=float(lng))
        #status = NhaTuyenDung.Add(keyLocal, TenThuongHieu, MieuTa, Email, SoDienThoai, LinhVucID, NguoiLienHe, QuiMoID, AnhDaiDien,  Website, ViTriText, ViTri, TrangThaiID, NguoiDungID)
        #status = NhaTuyenDungEntities.UpdateService(keyLocal, 217,TenThuongHieu, MieuTa, SoDienThoai, LinhVucID, "Long than dong", QuiMoID, AnhDaiDien,  Website, ViTriText, lat, lng)
        NganhNgheID = 190
        TinhThanhID = 56
        NhaTuyenDungID = 217
        MucLuongID = 80
        DoiTuongs = [171]
        LoaiHinhID = 88
        CapBacID = 93
        YeuCau = "Khong"
        MieuTa = "Khong"
        ChucDanh = "Ky su truong"
        NgayKetThuc = "16/4/2011"
        #NgayKetThuc = datetime.datetime.strptime(NgayKT,"%d/%m/%Y" )
        NgayDang = datetime.datetime.now()
        TrangThaiID = TrangThaiEntities.GetID(Entities.GetKey(),u'Vừa nhập');        
        #status = DonDangTuyen.Add(keyLocal,NgayDang, NgayKetThuc, MieuTa, YeuCau, NhaTuyenDungID, NganhNgheID, ChucDanh, MucLuongID, LoaiHinhID, TinhThanhID, CapBacID,TrangThaiID, DoiTuongs)
        #status = DonDangTuyen.Update(keyLocal,228, "17/4/2011", MieuTa, "Khong co gi nhe :D", NganhNgheID, ChucDanh, MucLuongID, LoaiHinhID, TinhThanhID, CapBacID)
        #status = NhaTuyenDung.Get(keyLocal, 0,0,0,0)
        a = XmlUtilities.Application()
        #status = a.updateNhaTuyenDung(keyLocal, 217, TenThuongHieu, MieuTa, SoDienThoai, LinhVucID, "Long sieu nhien", QuiMoID, AnhDaiDien, Website, ViTriText,lat, lng)
        #status = XmlUtilities.Application.getNhaTuyenDung(a,keyLocal,0,0,0,0)
        #status = a.addDonDangTuyen(keyLocal, NgayKetThuc, "test xem nao", "Khong co gi", NhaTuyenDungID, NganhNgheID, "Truong phong", MucLuongID, LoaiHinhID, TinhThanhID, CapBacID)
        #status = DoiTuong.Delete(keyLocal, 168)
        #status = NhaTuyenDung.Get(Entities.GetKey(),"test34@example.com")
        #status = DoiTuong.Get(keyLocal, 0)
        #status = a.getDoiTuong(keyLocal,0)
        #status = DoiTuong.GetAll("aghsb25ndGRia3IQCxIJTmd1b2lEdW5nGOUBDA")
        #status = DonDangTuyen.Get(keyLocal,0,0,"","","",0,0,0,0,0,0,0,0)
        #status = DonDangTuyen.Get(keyLocal,0,0,"","","",0,93,0,0,0,0,0,0)
        #status = DonDangTuyen.UpdateTrangThai(keyLocal,228,u"Đang duyệt")
        #status = TrangThai.Get(keyLocal,0,"Hợp lệ")
        #status = NhaTuyenDung.GetLocationRadian(lat,lng, 0.03)
        #status = TuyenDungNguoiDungEntities.Get(Entities.GetKey(), 0)
        #status = a.addNhaTuyenDung(keyLocal, TenThuongHieu, MieuTa, Email, SoDienThoai, LinhVucID, NguoiLienHe, QuiMoID, AnhDaiDien,  Website, ViTriText, lat, lng, NguoiDungID)
        #status = a.getNhaTuyenDungRad(lat,lng, 0.1)
        #status = a.getCompany(lat,lng, 0.1)
        #status = DonDangTuyenEntities.GetDt_NhaTD(Entities.GetKey())
        #status = TuyenDungNguoiDungEntities.Add(Entities.GetKey(),282)
        #status = TuyenDungNguoiDungEntities.Get(Entities.GetKey(),0)
        #status = NhaTuyenDungEntties.
        #status = a.UpdateService(keyLocal, 217,TenThuongHieu, MieuTa, SoDienThoai, LinhVucID, "Long tdgegege", QuiMoID, AnhDaiDien,  Website, ViTriText, lat, lng)
        #status = DoiTuongEntities.Get(keyLocal, 0)
        #status = NhaTuyenDungEntities.UpdateService(keyLocal, 217,TenThuongHieu, MieuTa, SoDienThoai, LinhVucID, "Longtdhdhdhdh", QuiMoID, AnhDaiDien,  Website, ViTriText, lat, lng)
        #status = DonDangTuyenEntities.Delete(Entities.GetKey(),128)
        #status  = a.getAllDonDangTuyen(0,0,"C","","",0,0,0,0,0,0,172)
        #status = DonDangTuyenEntities.All(0,0,"","","",0,0,0,0,0,0,0,172)    TrangThai
        #status = DonDangTuyenEntities.Get(Entities.GetKey(),0,0,"","","",55,93,166,0,0,158,160,172)
        #status = DonDangTuyenEntities.Get(Entities.GetKey(),0,0,"K","","",297,0,0,0,0,0,0,0)
        #status = DonDangTuyenEntities.All(0,0,"K","","",217,0,0,0,0,0,0,0)
        #status = DangTuyenDoiTuongEntities.GetIDDangTuyen(Entities.GetKey(), 172) #172
        #status = DonDangTuyenEntities.Get(Entities.GetKey(),0,0,"N","","",62001,68001,0,27002,28001,47001,46002,0)
        #status = DonDangTuyenEntities.Get(Entities.GetKey(),0,0,"","","",0,0,0,0,0,0,0,0)
        #status = DangTuyenDoiTuongEntities.Add(Entities.GetKey(), 154, 171) #172
        template_values = {
            'menu' : HtmlTemplate.Menu(),
            'footer': HtmlTemplate.Footer(),
            #'status':status,
            #'tuyendung' :trangthai.TenTrangThai
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/index.html')
        self.response.out.write(template.render(path, template_values))
class Service(webapp.RequestHandler):
    def get(self):
        template_values = {
            'menu' : HtmlTemplate.Menu(),
            'footer': HtmlTemplate.Footer()
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/services.html')
        self.response.out.write(template.render(path, template_values))        

class AboutUs(webapp.RequestHandler):
    def get(self):
        template_values = {
            'menu' : HtmlTemplate.Menu(),
            'footer': HtmlTemplate.Footer()
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/about-us.html')
        self.response.out.write(template.render(path, template_values))    

class ContactUs(webapp.RequestHandler):
    def get(self):
        template_values = {
            'menu' : HtmlTemplate.Menu(),
            'footer': HtmlTemplate.Footer()
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/contact-us.html')
        self.response.out.write(template.render(path, template_values))    

class SiteMap(webapp.RequestHandler):
    def get(self):
        template_values = {
            'menu' : HtmlTemplate.Menu(),
            'footer': HtmlTemplate.Footer()
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/sitemap.html')
        self.response.out.write(template.render(path, template_values))    

class TestAndroid(webapp.RequestHandler):
    def get(self):
        template_values = {
            }
        path = os.path.join(os.path.dirname(__file__), '../templates/testAndroid.html')
        self.response.out.write(template.render(path, template_values))      